package com.laicunba.util;

import java.util.Map;

public class CacheUtil {

	public static String getAttribute(String name) {
		return RedisUtil.get(name);
	}

	public static Object getObjAttribute(String name) {
		return RedisUtil.getObj(name);
	}

	public static void setAttribute(String name, String value, int seconds) {
		RedisUtil.set(name, value, seconds);
	}

	public static void setAttribute(String name, String value) {
		RedisUtil.set(name, value);
	}

	public static Long removeAttribute(String name) {
		return RedisUtil.del(name);
	}

	/**
	 * 自增变量,超过有效期重新计0
	 * 
	 * @param key
	 * @param seconds
	 * @return
	 */
	public static long incr(String key, int seconds) {

		return RedisUtil.incr(key, seconds);
	}

	public static String rpop(String key) {
		return RedisUtil.rpop(key);
	}

	public static boolean  hset(String key, String field, String value) {
		return RedisUtil.hset(key, field, value); 
	}

	public static void hmset(String key, Map<String, String> mset) {
		RedisUtil.hmset(key, mset); 
	}

	public static String hget(String key, String field) { 
		return RedisUtil.hget(key, field);
	}

	public static Long hdel(String key, String ...fields) {
		return RedisUtil.hdel(key,fields);
	}

	public static Map<String, String> hgetAll(String key) {
		return RedisUtil.hgetAll(key);
	}

	public static long expire(String key, int seconds) {
		return RedisUtil.expire(key,seconds);
	}

}
